<h1>Listing exams taken by students</h1>
<% @exams.each do |exam| %>
	<p>
		<h2><%=h exam.title %>: </h2><br/>
		Students who have taken this exam: <br/>
		<table>
			<tr>
				<th>Name</th>
				<th>Date</th>
				<th>Grade</th>
			</tr>
			<% exam.exam_results.sort_by { |r| r.time }.each do |result| %>
				<tr>
					<td><%=h result.user.last_name %> </td>
					<td><%=h result.time %></td>
					<td><%=h get_grade(result) %></td>
					<td> 
						<%= link_to 'Show', :action => 'show', 
											:id => result.id %>
					</td>
					<td>
						<%= link_to 'Destroy', { :action => 'destroy', 
											     :id => result.id
											   }, :confirm => 'Are you shure?',
											   	  :method => :post %>
					</td>
				</tr>
			<% end %>
		</table>
	</p>
<% end %>

<%= link_to 'Previous page', { :page => @exam_pages.current.previous } \
		if @exam_pages.current.previous %>
<%= link_to 'Next page', { :page => @exam_pages.current.next } \
		if @exam_pages.current.next %> 
